require.config({
    baseUrl:baseUrl
});

define(function(require){
    var $ = require('jquery');
    window.$ = window.jQuery = $;

    $(function(){
		//调用微信JS api 支付
		function jsApiCall(){
			WeixinJSBridge.invoke(
				'getBrandWCPayRequest',
				jsApiParameters,
				function(res){
					 if(res.err_msg == "get_brand_wcpay_request:ok" ){
						 var returnURL = SITEURL + "/Info/detail?id=" + orderid;
					 }else{
						 var returnURL = SITEURL + "/Info/detail?id=" + orderid;
					 }
					 location.href = returnURL;
				}
			);
		}
		
		function callpay(){
			if (typeof WeixinJSBridge == "undefined"){
			    if( document.addEventListener ){
			        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
			    }else if (document.attachEvent){
			        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
			        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
			    }
			}else{ 
			    jsApiCall();
			}
		}
		
		$('.callwxpay').click(function(){
			callpay();
		});
		
		var order_status = parseInt($('#order_status').val());

		if(order_status == 1) callpay();
    });
	
	
});
